package com.ice.cloud.payManagement.controller;
import com.ice.cloud.comm.dto.FeeDeductionDTO;
import com.ice.cloud.comm.resp.R;
import com.ice.cloud.payManagement.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

// 支付管理模块
@RestController
@RequestMapping("/pay")
@RefreshScope
public class PayController {
    @Autowired
    AccountService accountService;

    @Value("${config.info}")
    private String configInfo;

    @GetMapping(value = "getConfigInfo")
    public R<String> getConfig(){
        return R.success(configInfo);
        // return R.success();
    }

    // 验证项目
    @GetMapping(value = "hello")
    public R<String> hello(@RequestParam("id")String id){
        // return R.success( "hello" + id);
        return R.success("hello" + id);
    }


    // 扣费
    @PostMapping(value = "feeDeduction")
    public R<String> feeDeductionForm(@RequestBody FeeDeductionDTO form) {
        // try {
        //     Thread.sleep(3000);
        // } catch (InterruptedException e) {
        //     e.printStackTrace();
        // }

        R<String> r = accountService.feeDeduction(form.getId(),form.getMoney());
       r.setData(r.getData()+"_1");
        return r;
    }

    // 扣费
    // @PostMapping(value = "feeDeduction")
    // public R<String> feeDeductionForm(@RequestBody FeeDeductionDTO form){
    //     R<String> r = accountService.feeDeduction(form.getId(),form.getMoney());
    //     r.setData(r.getData()+"_2");
    //     return r;
    // }
}
